package 
{
	import com.inruntime.utils.Global;
	import config.APPRES;
	import config.COLORCONFIG;
	import data.DataMonitor;
	import down.Downloader;
	import flash.display.Sprite;
	import flash.events.Event;
	import frame.MainPage;
	import nsdecl.ns_singleton;
	import proxy.DataAccess;
	import ui.ui_background;
	import ui.uiRadioGroup;
	import vndecl.*;
	
	/**
	 * 项目入口
	 * @author anod
	 */
	public class Main extends Sprite 
	{
		private var frameSp:Sprite;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			loadResource();
			loadUIcomponents();
			applicationStart();
		}
		
		private function applicationStart():void
		{
			setupRuntimeConfig();
			
			var control:DataAccess = DataAccess.instance;
			control.initial();
			
			var dlg:MainPage = new MainPage();
			frameSp.addChild( dlg );
		}
		
		private function setupRuntimeConfig():void
		{
			frameSp = new Sprite();
			addChild( frameSp );
			
			var drag_layout:Sprite = new Sprite();
			drag_layout.mouseChildren = drag_layout.mouseEnabled = false;
			addChild( drag_layout );
			
			var tips_layout:Sprite = new Sprite();
			tips_layout.mouseChildren = tips_layout.mouseEnabled = false;
			addChild( tips_layout );
			
			Global.getInstance().stage = stage;
			Global.getInstance().tipsLayout = tips_layout;
			Global.getInstance().dragLayout = drag_layout;
		}
		
		private function loadResource():void
		{
			img0108;
			img0131;
			img0110;
			img0160;
			img0162;
			img0111;
			img0122;
			img0112;
			img0123;
			img0165;
			img0134;
			img0237;
			img0239;
			img0240;
			img0228;
			img0252;
			img0258;
			img0236;
			img0197;
			img0198;
			img0118;
			img0266;
			img0299;
			img0254;
			img0307;
			img0304;
			img0628;
		}
		private function loadUIcomponents():void
		{
			ui_background;
			uiRadioGroup;
			DataMonitor.updateData( COLORCONFIG, VNGC.COLOR );
		}
	}
}